from django.contrib.gis import admin
from report.models import *
from django.http import HttpResponseRedirect

def mark_as_replicate(modeladmin, request, queryset):
    for spr in queryset:
        spr.mark_replicate_true()
    return HttpResponseRedirect('./')
    
def save_to_set_date_modified(modeladmin, request, queryset):
    for spr in queryset:
        spr.save()
    return HttpResponseRedirect('./')
    
class SpacingPointReplicationAdmin(admin.GeoModelAdmin):
    list_display = ('point','habitat','lop','replicate','date_modified',)
    list_filter = ('point','habitat','lop','replicate','date_modified',)
    actions = [mark_as_replicate,save_to_set_date_modified]
admin.site.register(SpacingPointReplication,SpacingPointReplicationAdmin)

class ContinuousProxyLineAdmin(admin.GeoModelAdmin):
    pass
admin.site.register(ContinuousProxyLine, ContinuousProxyLineAdmin)

class ShoreLineAdmin(admin.GeoModelAdmin):
    pass
admin.site.register(ShoreLine, ShoreLineAdmin)

class Contour30mAdmin(admin.GeoModelAdmin):
    pass
admin.site.register(Contour30m, Contour30mAdmin)

admin.site.register(SpacingReportCache)